﻿using System;
using System.Globalization;
using System.Threading;

namespace NMA.Web.Core.Extensions
{
    public static class DateTimeHelper
    {
        /// <summary>
        /// http://msdn.microsoft.com/en-us/library/az4se3k1%28VS.71%29.aspx
        /// </summary>
        /// <param name="dateTime">date time that want to format</param>
        /// <param name="formatSpecifier">format specifier</param>
        /// <returns>string formatted</returns>
        public static string FormatDateTimeWithCurrentCulture(this DateTime dateTime, string formatSpecifier)
        {
            CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
            return dateTime.ToString(formatSpecifier, currentCulture);
        }
    }
}